/*
 * ipudp.h
 *
 *  Created on: 15 Aug 2012
 *      Author: jaxensal
 */

#ifndef IPUDP_H_
#define IPUDP_H_

/*
**  udpip.h
**  UDP/IP for LPC17XX
*/

void udpipInit(unsigned char* mymac, unsigned long myip);
/*
 * Initializes Ethernet controller and sets up receive and transmit buffers.
 * This implementation does not use interrupts.
 */
void udpipExit(void);
/*
 * Uninitializes the Ethernet controller in case needed.
 */
void udpipWork(void);
/*
 * Handles all necessary ARP and ICMP work and processes received UDP messages
 * through a service callback mechanism.
 * This function has to be called repeatedly.
 */
short udpipSend(short service, void* msg, short len);
/*
 * Sends message back to the saved sender for the specified service.
 */
short udpipSetService(short service, unsigned short port, void (*callback)(unsigned char* msg, short len, unsigned char broadcast));
/*
 * sets up service with port and callback;
 * callback will be called when messages are received for this port.
 * callback function should already know the service number for which it is set.
 */
void udpipSaveRemoteForService(short service);
/*
 * stores MAC address, IP address and port number of current sender
 * for the specified service.
 */
short udpipRemoteIsRemoteForService(short service);
/*
 * returns -1 if the Remote's MAC, IP and Port are the same as the
 * last saved values.
 */
void udpipSetBroadcastForService(short service, unsigned short port);
/*
 * set the MAC and IP address of sender for current sender for
 * the specified service to broadcast addresses.
 */
void udpipActivity100MOn(void);
/*
 * To be supplied by modules using udpip
 * Called when receiving or sending on 100M connection
 */
void udpipActivity10MOn(void);
/*
 * To be supplied by modules using udpip
 * Called when receiving or sending on 100M connection
 */
void udpipActivityOff(void);
/*
 * To be supplied by modules using udpip
 * Called when at end of receiving or sending
 */

#endif /* IPUDP_H_ */
